HP2TEX

A converter for HPGL–Files to emTEX

Version 0.96

Axel Braun Contents

1. Introduction 3

2. General purposes 3

3. HP2TEX 3 3.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.2 What else is needed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3 Supported HPGL–commands . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.4 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.5 Line Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.6 Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.7 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4. HPopt 7 4.1 Why HPopt? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.2 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.3 Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.4 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5. License 9

6. Disclaimer 9

7. Bugs 10

8. Sources 10

9. Virus Check 10

10.Examples 11

List of Figures

1 Output of a technical chart–program, processed with TEXcad. . . . . . . . 11

2 Finite–Element–grid with 696 lines (for calculation of an EMC–problem) . 12

3 Result of the calculation: Aequipotential lines (cut out) . . . . . . . . . . 12

4 Demo from Drafix WinCAD: a house (processed with /H190 /R+) …. 13

1. Introduction

Typesetting with TEX is really a fine thing. It obtains an advantageous handle for tabulars, formulars and so on. But the possibilities to create charts or include them have not been the best.

A program called TEXcad (submitted with emTEX) permits drawing of pictures, but how to include the results of a measurement, a plot or something like this into emTEX? Many chart programs offer an output to a plotter. Together with emTEX’s capability to draw lines of any gradient, the solution seemed to be clear: A tool is needed to convert a HPGL – file to emTEX, so I started with HP2TEX. The output HP2TEX produces is ’compatible’ to TEXcad, so the pictures can be processed with this program.

Another way to include graphics into emTEX usage of PCX–files. This may be advantageous for complex arrangements like the grid in Fig. 2, but for charts I prefer the direct way (Beside several other aspects: I don’t like those ISO–fonts in most HPGL–plots). Nevertheless, with use of HP2TEX the output is still device–independent, and needs not to be generated for every different printer (resp. every different resolution) you use.

Complex figures like Fig.2 have a great number of redundant lines, which blow up the picture file in an unnecessary manner. Another program, called HPopt, looks for these double lines and tries to connect several lines with the same gradient to one single line. Beside this, another option offers the output as a single line (more or less). For details, see the description later in the manual.

2. General purposes

To run this software, you need at least a 286–Computer. It will not run on a XT. A numerical coprocessor is supported if available.

OS/2 users: When using HPopt, configure the DOS–Box for as much conventional memory as possible. The settings

VIDEO_MODE_RESTRICTION = MONO and DOS = HIGH, UMB

will give better results for large plot files.

3. HP2TEX

3.1 Usage

The use of HP2TEXis quite simple:

HP2TeX input [output] [options]

If all arguments are omitted, a little help is given. The arguments in detail:

Files input Your ASCII input file, with extension. output Your emTEX output file. If you omit [output], HP2TEX generates a file with

the extension .PIC .

Options (Arguments must follow without blank!) /I Use the scaling points that are set in the plot. HPGL’s IP instruction sets

scaling points to make sure that the plot is true to scale. With the /I–option, the width and height of the TEX–picture are set considering the scaling points. Otherwise they are set to the true chart–size.

/W Width of picture in millimeter. Default is 135 mm. Width overrides height, except only /H is specified. Width and height of the picture are independent from the choosen \unitlength!

/H Height of picture in millimeter. Default is 135 mm. /U \unitlengh in millimeter. Default is 1 mm. /Px.x \linethickness in [pt]. The default is 0.1pt for all lines. Usually a plotter has

6 pens,sometimes more. For maximal 6 pens you can select a linethickness. For example, if you type /P1.00.50.8 you have selected the following:

Pen 1 linethickness 1.00pt
Pen 2 linethickness 0.50pt
Pen 3 linethickness 0.80pt

/R Rotate the output for 90 degrees. If you choose /R or /R+, the output is rotated for +90 degrees (counterclockwise). /R- rotates the output –90 degrees (clockwise)

Example:

  HP2TeX dummy.1 dummy.2 /h100 /R- /u0.25

This command processes the file dummy.1, limits the height to 100mm, chooses a Unitlength of 0.25mm, rotates the output for –90 degrees and stores the result in dummy.2 . To include this in your emTEX–document, just type:

\begin{figure}
\centering
\input{dummy.2}
\caption{\label{dummy} This is dummy.2 !}
\end{figure}

3.2 What else is needed?

The compatibility to TEXcad requires a special macro. This macro is called \emline and you must include it in your document. \emline is from the style emlines2.sty, written by Georg Horn / Eberhard Mattes and part of the TEXcad – Package. The macro \emline, taken from the file emlines2.sty, is listed below:

\def\emline#1#2#3#4#5#6{%
       \put(#1,#2){\special{em:moveto}}%
       \put(#4,#5){\special{em:lineto}}}

3.3 Supported HPGL–commands

HP2TEX supports the following commands of the HP 7475 A instruction set: AA, AR, CI, CP, DF, DI, DT, DR, IN, IP, LB, LT, PA, PD, PR, PU, RO, SC, SP, XT, YT . This is enough for most pictures, like Fig.4. Some more commands will be supported in later releases.

HP2TEX assumes the paper size A4 as plotter default. Any Initialize (IN) or Default (DF) commands set the scaling points to the plotter units (603,521) and (10603,7721) resp., for rotated output (RO), to (0,610) and (7200,10610). Any following scale – command (SC) uses these values, if no other values are given.

What does this mean?

If your program, for example, is configured to tell your plotter to print in landscape mode, the picture you see after processing with HP2TEX might be rotated for 90 degrees. You can correct this with /R–, but this does not change the ratio of the picture. The ratio of the picture can only be changed with the program that produces the HPGL – output. Be sure that your HPGL – output is configured for an A4 – plotter, the paper – size of A or B paper is different!

3.4 Labels

Since Version 0.95, the usage of HPGL’s Label (LB) – command is supported. Different to the plotter, various character–sets are not supported. This is needless because you have variety of the great number of fonts TEX places at disposal. Therefore, it is not necessary to vectorize the labels. Instead, the text of any label is enclosed by a box, which is placed by a \put[] according to the reference point of this text (which is at the lower left corner of the box).

So, if the LB – command is used, the following can happen:

1. The text isn’t where you want it. This is caused by the different size of the plotter’s character’s and the fonts TEX uses. To minimize these effects, the text of the label is enclosed by a box with the width of the text in the plot. By default, the text is placed left in the box (can be changed with the parameters of the makebox).

To get a defined height, HP2TEX cooses a font with regard to the height of the characters. For independency from the actual font size of your document, the basic names are used: a 10pt Roman is called \tenrm, a 17pt Roman \svtnrm and so on. These names are defined in the file \emtex\texinput\lfonts.tex. Nevertheless, the dimensions of the fonts TEX uses are quite different than HPGL’s standart characters. So, it is still possible that you have to do little changes by hand. (Dont’t panic now, first take a look at your output!)

2. The text in the box is not the same as in the plot. This happens if any math, italic, slanted, in general non–roman characters are in the label (see above). Take your editor and change the boxes, change the (for example) \tenrm to a \tenit for that it looks the way you want it. The boxes are placed at the beginning of the picure file, right after the \begin{picture}.

3. You have choosen rotated output (/R). If you can persuade TEX to place your boxes vertically, GREAT, just let me know! Generally it’s not possible to rotate the box, but if it comforts you: The reference points are still right!

4. Vertical direction of Labels: In this case the content of the label looks like

\parbox[t]{1em}{T\\e\\x\\t} instead of \makebox(0,0)[bl]{Text}. Depeding

on the direction of the plot a [b] might appear as parameter.

3.5 Line Types

HPGL is aware of eight several Line Types. HP2TEX V 0.96 supports these Types according to the HP7475 command–set:

Default Type 0 Type 1 Type 2 Type 3 Type 4 Type 5 Type 6

The default type is a solid line. Type 0 has only dots at the start of the line, Type 1 at the the start of each line–pattern. The length of each pattern is set in the plot. To produce a dot (should be of dimension Zero!), a short line of approx. one plotter unit is painted. All other lines are painted with regard to their pattern–length.

3.6 Compatibility

HP2TEX was used with the output of several programs, such as technical chart programs (GNUPlot, TechPlot) or CAD programs (AutoCAD, WinCAD). Beside this, the output of Finite–Element–programs was used. No problems were detected (... I think, that doesen’t mean anything). Examples are at the end of this doc.

The output of HP2TEX is in a manner that allows processing with TEXcad. If you use several pens (linethickness), TEXcad may run into trouble, because several pens are not supported. But usually it offers the right assignment.

3.7 Problems

Sometimes the rendering device might change the desired linethickness a little bit, so that the lines look different. In this case, change the linethickness to one dot or multiple of this (Can be done with any editor). For the HP Laserjet (300dpi), one dot is about 0.003333in. Maybe in a later release the linethickness is changed to single dots, depending on the resolution (if you think this is advantageous, let me know).

With very large files the error–message

TeX capacity exceeded.....

may occur. This is a problem with the –86, –186, –286 version of emTEX, if any buffer is too small. With tex386, this problem should not occur.

Older versions of the dvidrivers may have an overflow. This problem does not appear with the dvidrivers 1.4r. Nevertheless, big pictures slow down the drivers.

4. HPopt

4.1 Why HPopt?

The main goal of HPopt was to reduce the number of lines before processing with HP2TEX and emTEX. For an example, regard Fig.2. This is the part of a Finite–Element– grid for the calculation of an electric field. Original, it contains 7342 lines. Double–line– search reduces this to 3932 lines. Connecting all neighboured lines with the same gradient to a single line reduces the number of lines to 696. This is one of the pictures you also can include as PCX–file.

HPopt uses Quicksort to order all lines with regard to their gradient (this can be suppressed with /N). Then it looks whether the lines are connectable. Lines of length Zero are always deleted, even if /N is specified.

4.2 Usage

The same a before:

HPopt input output [options]

If all arguments are omitted, a little help is given. If you omit the options, HPopt tries to connect all neighboured lines with the same gradient (You can suppress this with /N).

The arguments in detail:

Files input Your ASCII input file, with extension. output Your output file. If you omit [output], HPopt terminates with an error. Options (Arguments must follow without blank!) /D Double line search. HPopt tries to find all double, not all hidden lines. It only

finds hidden lines, if they have a common starting or end point with another line. If double lines use different pens, the line with the lower pen – number is deleted. (It is assumed, that great pen numbers use thicker pens)

/P Optimize lines without regard of different pens. Pen 1 is set for all lines /S Slow optimization. To connect all lines with the same gradient, this option does

not use Quicksort to sort the lines regarding to their gradient. This option is in general slower than the default, but can’t cause a (trapped) stack overflow.

/A All in one. Tries to write the output as a single line. When using this option,

writing the output can take a considerable amount of time.

/Mxx minimal gradient difference in degree. HPopt sets all lines with gradient differ-

ence smaller than xxxx degree (default is 0.01 degree) to the same gradient.

/N Don’t connect lines with same gradient. If only this option is specified, HPopt does nearly nothing except deleting zero–length–lines.

Note: Reducing the number of lines might take a considerable amount of time!

HPopt’ s version 0.1 allows the pen – sensitive otimization. At first the pen with the lowest number of lines is optimized, the last pen is the one with the greatest number of lines. This proceeding can save time and stack space. You can suppress the pen – sensitive work with the /P option.

All commands that will not allow an optimization, especially arc– and circle – commands, are not processed. You’ll find them at the beginning of the output – file.

4.3 Restrictions

HPopt does not process the plot file explicit, what means, that the input data is not translated with regard to paper size or scale–commands. HPopt uses the input data ’as it is’. So, we run into trouble if one of the following happens:

1. Non-integer data in the input. Refers only to lines, and can be changed if necessary. The change to support all input data will enlarge the processing time. (Because most plots use only integer data, it seemed to me not to be a real restriction)

2. The plot is re–initialized. Unusual, but possible. For the moment, this might produce a strange result.

3. Several line – types (LT) occur. For the moment this is not supported, so you’ll have only solid lines.

4.4 Problems

Many problems have been fixed with the release 0.02. Generally, when working in default mode, a problem with the stack–size can occur. Because the Quicksort–algorithm works recursive, much place on the stack is needed. The maximal stack–size is limited to 64k, and if this is too small, the program stops with an error message while sorting. In this case, restart the program with the /S option.

All other error messages, that are not displayed by text, refer to the error numbers of Basic PDS resp. QuickBasic.

5. License

The HP2TEX software is copyright \begin{matrix}c \\ ◯ \end{matrix} 1992 – 93 Axel Braun, all rights reserved, except emlines2.sty, written by Georg Horn / Eberhard Mattes. HP2TEX software may not be circulated in any incomplete or modified form, nor sold for profit, without written permission of the author.

This software is free may be copied free. If you distribute this software to others, you are required to distribute the ENTIRE package consisting of the following files:

HP2TEX.EXE  History
HPopt.EXE  What it.is
HP2TXMan.DVI  emlines2.sty

6. Disclaimer

This software (HP2TEX, HPopt) is provided on an ”as is” basis without warranty of any kind, expressed or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. The person using the software bears all risk as to the quality and performance of the software. The author will not be liable for any special, incidental, consequential, indirect or similar damages due to loss of data or any other reason, even if the author or an agent of the author has been advised of the possibility of such damages. In no event shall the author’s liability for any damages ever exceed the price paid for the license to use the software, regardless of the form of the claim.

7. Bugs

Please report bugs (best together with the plot file), suggestions, congratulations and everything else to:

Axel Braun Lüneburger Weg 11c D – 40468 Düsseldorf Internet: hl418br@duc220.uni-duisburg.de (may change)

Due to changes, the EMail address is not used frequently. You may try hl421ge@....., the message will be forwarded to me. If you enclose any files, please pack (ARJ, ZIP, ...) and uuencode them.

You’ll definitely get an answer using a letter (and a disk, maybe)!

8. Sources

The programs were compiled with Basic–PDS 7.1. The source code can be submitted by request. Please report any changes or suggestions to the author. This will be a help for further releases.

9. Virus Check

The check with McAfee’s VALIDATE.COM 0.4 should give the results:

HP2TEX 0.96 :

          File Name:  hp2tex.exe
               Size:  64,074
               Date:  5-27-1993
File Authentication:
     Check Method 1 - 45A5
     Check Method 2 - 1F05

HPopt 0.11 :

                                                      File Name:  hpopt.exe
                                                           Size:  67,212
                                                           Date:  5-27-1993
                                            File Authentication:
                                                 Check Method 1 - EC8C
                                                 Check Method 2 - 152F

10. Examples

0  0.5  1.0  1.5 −0.50 −0.25 0 0.25 0.50 0.75 1.00  d/b p, c/b  p c/b

Figure 1: Output of a technical chart–program, processed with TEXcad.

Figure 2: Finite–Element–grid with 696 lines (for calculation of an EMC–problem) Figure 3: Result of the calculation: Aequipotential lines (cut out)

Figure 4: Demo from Drafix WinCAD: a house (processed with /H190 /R+) 13